﻿using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using DQS.Core.Log;

/// <summary>
/// DQS Basic Page
/// </summary>
public class DQS_Page : System.Web.UI.Page
{
    private const string _defaultPass = "123456";

    public static string DefaultPass
    {
        get { return DQS_Page._defaultPass; }
    } 

    public DQS_Page() { }

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        if (Session["LoginUser"] == null)
        {
            Log.Instance(this).Info("{ClientIP:'" + Tool.GetClientIP() + "',Msg:'Session['LoginUser'] doesn't exist.'}");
            Response.Write("<script type='text/javascript'>window.top.location.href='../login.aspx';history.go(1);</script>");
            Response.End();
        }
    }

    #region Protected Method
    protected void Alert(string argMessage)
    {
        this.Alert("", argMessage);
    }

    protected void JQueryAlert(string argMessage)
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(), "sysinfo", "$(function(){alert('" + argMessage + "');});", true);
    }

    protected void Alert(string argKey, string argMessage)
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(), argKey, "alert('" + argMessage + "');", true);
    }    

    protected void AlertThenRedirect(string argMessage, string argHref)
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('" + argMessage + "');location.href='" + argHref + "'", true);
    }
    #endregion
}
